package cn.hx.malluser.controller;

import cn.hx.malluser.entity.UmsMember;
import cn.hx.malluser.service.UmsMemberService;
import cn.hx.malluser.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class UmsMemberRegisterController {

    @Autowired
    private UmsMemberService umsMemberService;

    /** 手机号码验证 */
    @PostMapping("/phoneVerify")
    public String phoneVerify(String phone, ModelMap map) {
        System.out.println("注册手机号：" + phone);
        map.addAttribute("phone", phone);
        return "sign-up-two";
    }

    /** 注册信息提交 */
    @PostMapping("/register")
    public String register(UmsMember umsMember) {
        System.out.println("注册信息==>" + umsMember);
        String password = umsMember.getPassword();
        umsMember.setPassword(MD5Util.encrypt(password));
        umsMemberService.save(umsMember);
        return "sign-up-last";
    }

}
